package com.qianf.qfoffice.controller;


import com.qianf.qfoffice.entity.Askforleave;
import com.qianf.qfoffice.entity.ResponseData;
import com.qianf.qfoffice.entity.User;
import com.qianf.qfoffice.service.AskforleaveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

@RestController
@RequestMapping("/AskForLeave")
public class AskforleaveController {

    @Autowired
    private AskforleaveService askforleaveService;

    /**
     * 添加请假信息
     * @param session
     * @param
     *
     * @return
     */
    @RequestMapping("/insertLeave.do")
    public ResponseData insertLeave(HttpSession session, Askforleave askforleave){

        ResponseData<Object> responseData = new ResponseData<>();

        User user = (User) session.getAttribute("user");
        askforleave.setUid(user.getId());
        int i = askforleaveService.insertAskforleave(askforleave);

        if (i > 0){
            responseData.setCode(0);
            responseData.setMsg("提交成功");
        }else {
            responseData.setCode(1);
            responseData.setMsg("失败");
        }
        return responseData;
    }



}
